import { createStore, applyMiddleware, compose } from "redux";
// import reduxLogger from 'redux-logger'; //操作日志--暂时不用
import reduxThunk from 'redux-thunk'; //同步异步
import reduxPromise from 'redux-promise'; //异步请求
import { routerMiddleware } from 'react-router-redux'; //redux中使用路由 

import reducer from "./rootReducer";

// let createHistory = require('history').createBrowserHistory;
let createHistory = require('history').createHashHistory;
let history = createHistory();  //初始化路由
let routerWare = routerMiddleware(history)

declare global {
    interface Window {
        __REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: typeof compose;
    }
}

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; //这是让redux-tools调试工具生效

let store = createStore(reducer, composeEnhancers(applyMiddleware(reduxThunk, reduxPromise, routerWare)));

export default store




/*
 * REDUX中间件
 *   redux-logger：能够在控制台清晰的展示出当前REDUX操作的流程和信息(原有状态、派发信息、修改后的状态信息)
 *
 *   redux-thunk：处理异步的DISPATCH派发
 *
 *   redux-promise：在DISPATCH派发的时候支持PROMISE操作
 */
